package com.atguigu.srb.controller;

import com.atguigu.srb.common.result.R;
import com.atguigu.srb.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/sms")
public class SmsController {
    @Autowired
    SmsService smsService;
    /*
        前端提交手机号获取验证码
            url/xxx?k=v&k2=v2


     */
    @GetMapping("{mobile}") // /api/sms/13511111111 => /api/sms/{mobile}     表示路径中的最后一级当作mobile变量的值使用
    public R  sendMessage(@PathVariable("mobile")String mobile){
        smsService.sendMessage(mobile);
        return R.ok();
    }

}
